package com.itheima.goods.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.goods.pojo.Spec;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @Description 定义操纵category分类的dao接口
 * @Created by itheima
 */
@Mapper
public interface SpecDao extends BaseMapper<Spec> {
        /**
         * 查询所有分类信息
         * @return
         */

        @Select("select \n" +
                "  tb_category.* \n" +
                "from\n" +
                "  tb_spec , tb_category_spec,  tb_category  \n" +
                "where tb_spec.id= ${id} \n" +
                "  and tb_spec.id = tb_category_spec.spec_id\n" +
                "  and tb_category_spec.category_id = tb_category.id ")
        List<Spec> findAll(@Param("id") Integer id);

        /**
         * 添加规格
         * @param
         * @return
         */
        @Insert("insert into `tb_spec` values ( null,${name},null)")
        List<Spec> findadd(@Param("spec") Spec spec);

        /**
         * 根据id更新
         * @param
         * @return
         */
        /*@Update("update tb_spec set name=${name},options=${options},seq=${seq}  where id= ${id}")
        Integer update(@Param("id") Integer id,@Param(name));*/

        /**
         * 根据id删除
         * @param id
         * @return
         */
        @Delete("delete from tb_spec where tb_spec.id= ${id}")
        Integer Delete(@Param("id") Integer id);

        @Update("update tb_spec set name=${name},options=${options},seq=${seq} where id=${id}")
        Integer updatespec(@Param("id") Integer id,@Param("name") String name, @Param("options") String options,@Param("seq") Integer seq);

}
